package com.gxsf.wechatbook.repo;

import com.gxsf.wechatbook.pojo.ReserUserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author BeijiRonin
 * @version 1.0.0
 * @date 2021/1/18 18:04
 */
public interface ReserUserInfoRepository extends JpaRepository<ReserUserInfo, Long> {
    ReserUserInfo findFirstByUserIdAndStatusOrderById(long userId, int status);

    List<ReserUserInfo> findAllByStatus(int status);

    @Transactional
    @Modifying
    @Query(value = "update reser_user_info set status =:#{#userInfo.status}  where id =:#{#userInfo.id}",nativeQuery = true)
    int update(ReserUserInfo userInfo);
}
